﻿using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;

namespace MAUILL
{
    [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
    public class MainActivity : MauiAppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.NMr1)
            {
                var shortcutManager = (ShortcutManager)GetSystemService(ShortcutService);
                var shortcut = new ShortcutInfo.Builder(this, "id2")
                    .SetShortLabel("新建任务")
                    .SetLongLabel("快速新建任务")
                    .SetIcon(Android.Graphics.Drawables.Icon.CreateWithResource(this, Resource.Mipmap.appicon))
                    .SetIntent(new Intent(Intent.ActionView, null, this, typeof(MainActivity)))
                    .Build();

                shortcutManager.SetDynamicShortcuts(new List<ShortcutInfo> { shortcut });
            }
        }
    }
}
